<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.ORM.entity.chainS.inventoryFlow.ChainInventoryFlowOrder"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<script>
var dataGrid ;
$(document).ready(function(){
	parent.$.messager.progress('close'); 	

	dataGrid = $('#dataGrid').datagrid({
		url : 'basicDataJSON!selectSystemFiles',
		fit : true,
		border : false,	
		checkOnSelect : false,
		selectOnCheck : false,
		nowrap : false,
		singleSelect: true,
		rownumbers : true,
		columns : [ [
 		    {	
				field : 'fileName',
				title : '文件名称',
				width : 230
			},{	
				field : 'filePath',
				title : '文件路径',
				width : 300			
			},{
				field : 'comment',
				title : '备注信息',
				width : 370
			},{
				field : 'fileSize',
				title : '文件大小',
				width : 200
			},  {
				field : 'createBy',
				title : '上传人员',
				width : 100	
			},{
				field : 'createTimes',
				title : '上传时间',
				width : 170		
			},{				
				field : 'action',
				title : '下载',
				width : 80,
				align: 'center',
			formatter : function(value, row, index) {
				var str = '';
				str += $.formatString('<a href="#" onclick="downloadFile(\'{0}\');"><img border="0" src="{1}" /></a>', row.fileName, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/download3.png');
								
				return str;
			}
		},{				
			field : 'action1',
			title : '删除',
			width : 80,
			align: 'center',
			formatter : function(value, row, index) {
			var str = '';
			str += $.formatString('<a href="#" onclick="deledeFile(\'{0}\');"><img border="0" src="{1}" /></a>', row.id, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/delete.png');
							
			return str;
		}
	}]],
		toolbar : '#toolbar',
	});

});

/**
 * 文件上传
 */
function save(){
    document.fileForm.action="productJSPAction!uploadFile";
    document.fileForm.submit();
}

/**
 * 文件删除
 */
function deledeFile(fileId){
		//这里可以把路径传入，后台判断，是否拥有此权限
	 var params= "formBean.systemFile.id=" + fileId +"&formBean.urlPath=" + "basicDataJSON!deledeFileById"; 
	 $.post("action/basicDataJSON!deledeFileById",params, deleteBkProcess,"json");
}
/**
 * 文件删除-回调
 */
function deleteBkProcess(date){
	if(date != null){
		$.messager.alert('删除提示',date.message,'info');
	}
	$('#dataGrid').datagrid('load',null); 
}

function downloadFile(fileName){
	$("#fileName").val(fileName);
    document.fileForm.action="productJSPAction!downloadFile";
    document.fileForm.submit();
}

</script>
</head>
<body>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 90px;">
	
	<s:form action=""
		method="POST" name="fileForm" id="fileForm"
		enctype="multipart/form-data" theme="simple">
		<input type="hidden" id="fileName" name="formBean.fileName"></input>
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" align="left" border="0">
						<tr class="PBAOuterTableTitale" align="left">
							<th colspan="3" height="25">文件管理:								
							</th>
						</tr>
						<tr class="InnerTableContent">
							
							<td width="30%"  align="right" height="41"><input class="easyui-filebox" id="inventory"  name="formBean.inventory" data-options="prompt:'请上传文件(注：文件名不能包含特殊字符（包含空格）)',buttonText: '系统文件',buttonAlign: 'left'" style="width:90%"></td>
							
							<td width="40%"><s:textfield cssClass="easyui-textbox" data-options="prompt:'请输入文件备注信息'" id="fileComment" style="width:50%" name="formBean.comment" size="50" />
								<s:if test="#session.LOGIN_USER.containFunction('productJSPAction!uploadFile')">
									<a href="#" class="easyui-linkbutton c8"  onclick="save();" >文件上传</a>
								</s:if>
							</td>
							<td>
								<s:actionerror cssStyle="color:red" />	<s:actionmessage cssStyle="color:blue" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</s:form>
	</div>	
	<div data-options="region:'center',border:false">
		<table id="dataGrid">
		</table>
		</div>
</div>
</body>
</html>